package wifi_locator_client.just.wzy.wifi_locator_client;


import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

import java.util.List;

/**
 * Created by Zhenyu on 2015/2/28.
 * wifi控制器
 */
public class WifiController {
    private WifiManager wifiManager;
    private List<ScanResult> scanResults;

    public WifiController(Context context) {
        wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    }

    /**
     * 打开wifi
     */
    public void openWifi() {
        wifiManager.setWifiEnabled(true);
    }


    /**
     * 关闭wifi
     */
    public void closeWifi() {
        wifiManager.setWifiEnabled(false);
    }

    /**
     * @return 返回扫描WiFi结果
     */
    public List<ScanResult> scanWifi() {
        wifiManager.startScan();
        scanResults = wifiManager.getScanResults();
        return scanResults;
    }


}
